<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // es5  构造函数 类
    // function Car(name, color) {
    //   this.name = name;
    //   this.color = color;
    //   this.jia = function () { }
    // }
    // Car.prototype.run = function () { }


    // es6 
    class Car {
      constructor(name, color) { //属性放置位置
        this.name = name;
        this.color = color;
      }
      jia() {
        alert("加")
      }
      run() {
        alert("跑")
      }
    }
    var qq = new Car("奇瑞qq", "蓝色");
    console.log(qq)

    // es6 类的继承
    //1. 子类 extends 父类
    //2. 调用super 方法
    class Weilai extends Car {
      constructor(price) {
        super("蔚来汽车", "蓝色")//2. 调用super 方法
        this.price = price;
      }
      shaoqian() {
        alert("烧钱");
      }
    }
    var weilai1 = new Weilai("40万");
    weilai1.run();
    weilai1.jia();
    console.log(weilai1.name)



  </script>
</body>

</html>